package grpc

import (
	"fmt"
	"google.golang.org/grpc"
	"net"
	"strconv"
)

func RegisterProductGrpc(host string, port int, call func(server *grpc.Server)) {
	listen, err := net.Listen("tcp", host+":"+strconv.Itoa(port))
	if err != nil {
		panic(err)
	}
	server := grpc.NewServer()
	call(server)
	fmt.Printf("register gRPC service at %v", listen.Addr())
	if err := server.Serve(listen); err != nil {
		panic(err)
	}
}
